#include "BlockPlacement.h"

BlockPlacement::BlockPlacement(sf::RenderWindow& app,
							   BlockPlacementCallback blockPlacementCallback)
: app_(app)
, callback_(blockPlacementCallback)
, wasMouseDown_(false)
{
}

BlockPlacement::~BlockPlacement(void)
{
}

void BlockPlacement::parseInput(const sf::Input& input)
{
	bool isMouseDown = input.IsMouseButtonDown(sf::Mouse::Left);
	if(wasMouseDown_ && !isMouseDown)
	{
		sf::Vector2f worldCoords = app_.ConvertCoords(input.GetMouseX(), input.GetMouseY());
		callback_(worldCoords.x, worldCoords.y);
	}
	wasMouseDown_ = isMouseDown;
}

